#!/usr/bin/env python
#_*_coding:utf-8 _*_
u'''
    模块用于读写文件
'''
__author__ = 'silence'
import pickle

#传入文件名参数，返回文件信息
def file_read(filename):
    try:
        f1 = open(filename,"rb")
        read_info = pickle.load(f1)
        f1.close()
        return read_info
    except IOError:
        read_info = {}
        return read_info

#写入write_info文件信息到文件中
def file_write(write_info,filename):
    f1 = open(filename,"wb")
    pickle.dump(write_info,f1)
    f1.close()
#读取日志
def read_log(file_name):
    try:
        f1 = open(file_name,"rb")
        log_info = pickle.load(f1)
        f1.close()
        return log_info
    except IOError:
        log_info = {}
        return log_info
#写入日志
def write_log(log_info,file_name):
    f1 = open(file_name,"wb")
    pickle.dump(log_info,f1)
    f1.close()
